<template>
  <div class="contain">
    <div class="psot" v-if="post">
      <!-- 三张图片 -->
      <div class="postMoreImg" v-if="post.images.length > 2">
        <nuxt-link :to="`/post/detail/?id=${post.id}`">
          <div class="postTitle">{{post.title}}</div>
        </nuxt-link>
        <nuxt-link :to="`/post/detail/?id=${post.id}`">
          <p class="content">{{post.summary}}</p>
        </nuxt-link>
        <nuxt-link :to="`/post/detail/?id=${post.id}`">
          <el-row class="img" type="flex" justify="space-between">
            <img :src="post.images[0]" />
            <img :src="post.images[1]" />
            <img :src="post.images[2]" />
          </el-row>
        </nuxt-link>
        <el-row class="postInfo" type="flex" justify="space-between">
          <div class="left">
            <span class="address">
              <i class="el-icon-location-outline"></i>
              {{post.city.name}} by
            </span>
            <nuxt-link to="#">
              <span class="user">
                <img :src="post.account.defaultAvatar" alt class="userImg" />
                <span class="name">{{post.account.nickname}}</span>
              </span>
            </nuxt-link>
            <span class="watch">
              <i class="el-icon-view"></i>
              {{post.watch}}
            </span>
          </div>
          <span class="right">66 赞</span>
        </el-row>
      </div>
      <!-- 有一张图片的 -->
      <el-row class="postOneImg" type="flex" v-if="post.images.length <= 2">
        <nuxt-link :to="`/post/detail/?id=${post.id}`">
          <img :src="post.images[0]" class="img" />
        </nuxt-link>
        <div class="right">
          <nuxt-link :to="`/post/detail/?id=${post.id}`">
            <div class="postTitle">{{post.title}}</div>
          </nuxt-link>
          <nuxt-link :to="`/post/detail/?id=${post.id}`">
            <p class="content">{{post.summary}}</p>
          </nuxt-link>
          <el-row class="bottom" type="flex" justify="space-between">
            <div class="left">
              <span class="address">
                <i class="el-icon-location-outline"></i>
                {{post.city.name}} by
              </span>
              <nuxt-link to="#">
                <span class="user">
                  <img :src="post.account.defaultAvatar" alt class="userImg" />
                  <span class="name">{{post.account.nickname}}</span>
                </span>
              </nuxt-link>
              <span class="watch">
                <i class="el-icon-view"></i>
                {{post.watch}}
              </span>
            </div>
            <span class="right">66 赞</span>
          </el-row>
        </div>
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    post: {
      type: Object,
      default: {}
    }
  }
};
</script>


<style lang="less" scoped>
.contain {
  width: 700px;
  .postMoreImg {
    width: 100%;
    padding: 20px 0;
    border-bottom: 1px solid #eee;
    .postTitle {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      margin-bottom: 15px;
      font-weight: 400;
      font-size: 18px;
      &:hover {
        color: orange;
      }
    }
    .content {
      font-size: 14px;
      color: #666;
      line-height: 1.5;
      // 多行省略
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
      overflow: hidden;
    }
    .img {
      margin: 15px 0;
      img {
        width: 220px;
        height: 150px;
      }
    }
    .left {
      font-size: 12px;
      color: #999;
      display: flex;
      .user {
        margin: 0 6px;
        display: flex;
        align-items: center;
        .userImg {
          display: block;
          width: 16px;
          height: 16px;
          border-radius: 100px;
          margin-right: 6px;
        }
        .name {
          color: orange;
        }
      }
    }
    .right {
      color: orange;
    }
  }
}
// 当个图片样式
.postOneImg {
  width: 100%;
  padding: 20px 0;
  border-bottom: 1px solid #eee;
  .img {
    width: 220px;
    height: 150px;
    margin-right: 10px;
  }
  .right {
    .postTitle {
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 1;
      overflow: hidden;
      margin-bottom: 15px;
      font-weight: 400;
      font-size: 18px;
      &:hover {
        color: orange;
      }
    }
    .content {
      font-size: 14px;
      color: #666;
      line-height: 1.5;
      // 多行省略
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
      overflow: hidden;
      margin-bottom: 15px;
    }
    .right {
      color: orange;
    }
    .bottom {
      .left {
        font-size: 12px;
        color: #999;
        display: flex;
        .user {
          margin: 0 6px;
          display: flex;
          align-items: center;
          .userImg {
            display: block;
            width: 16px;
            height: 16px;
            border-radius: 100px;
            margin-right: 6px;
          }
          .name {
            color: orange;
          }
        }
      }
    }
  }
}
</style>